﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessPlatform.Data;
using NewStartHanldingUI.Menus;
using NewStartModels.Models.Authorities;

namespace NewStartHanldingUI.CurrentUser
{
    public sealed class CurrentUser : ICurrentUser
    {
        #region constructor
        private CurrentUser()
        {
        }
        #endregion
        #region static varialbe
        /// <summary>
        /// 锁
        /// </summary>
        private static object mylook = new object();
        /// <summary>
        /// 当前用户实例
        /// </summary>
        private static CurrentUser curUser;
        #endregion
        #region 实例
        /// <summary>
        /// 类的实例
        /// </summary>
        public static CurrentUser Instance
        {
            get
            {
                if (curUser == null)
                {
                    lock (mylook)
                    {
                        if (curUser == null)
                            curUser = new CurrentUser();
                    }
                }
                return curUser;
            }
        }
        #endregion
        #region User properties
        /// <summary>
        /// 用户内部Id编号
        /// </summary>
        public int UserId { get; set; }
        /// <summary>
        /// 用户代码
        /// </summary>
        public string UserCode { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 用户密码
        /// </summary>
        public string Password { get; set; }
        /// <summary>
        /// 超级用户
        /// </summary>
        public Enumerator.BOYesOrNo IsSupperUser { get; set; }
        /// <summary>
        /// 登陆时间
        /// </summary>
        public DateTime LoginDateTime { get; set; }
        /// <summary>
        /// 登陆机器名称
        /// </summary>
        public string LoginMachineName { get; set; }
        /// <summary>
        /// 登陆IP
        /// </summary>
        public string LoginMachineIP { get; set; }
        /// <summary>
        /// 语言
        /// </summary>
        public string LoginLanguage { get; set; }
        #endregion

        public IList<IAuthoritier> Authors { get; set; }
        public IMenus Menus { get; set; }
    }
}
